< previous page page_904 next page >

Page 904
The AutoGenSQVOpen Method
Now add the AutoGenSQVOpen subroutine from Listing A.30. Notice that, if no name is supplied for the script, SQL-VB5 invents one based on the MDB name.
Type.gifListing A.30. Coding the AutoGenSQVOpen subroutine.
Public Sub AutoGenSQVOpen(Optional cSQV As Variant)
    On Error GoTo AutoGenSQVOpenErr
    '
    Dim intTemp As Integer
    '
    If IsMissing(cSQV) = True Or Len(cSQV) = 0 Then
        cWrFile = cDBName
    Else
        cWrFile = cSQV
    End If
    '
    intTemp = InStr(cWrFile, ".")
    If intTemp > 0 Then
        cWrFile = Mid(cWrFile, 1, intTemp - 1)
    End If
    cWrFile = cWrFile + ".sqv"
    '
    If IsMissing(cSQV) = True Or Len(cSQV) = 0 Then
        SQLVBMain.CommonDialog1.DialogTitle = "Create SQV File"
        SQLVBMain.CommonDialog1.DefaultExt = "SQV"
        SQLVBMain.CommonDialog1.Filter = "SQV Script File|*.SQV"
        SQLVBMain.CommonDialog1.filename = cWrFile
        SQLVBMain.CommonDialog1.Flags = cdlOFNCreatePrompt Or
arrow.gifcdlOFNOverwritePrompt
        SQLVBMain.CommonDialog1.CancelError = True
        SQLVBMain.CommonDialog1.ShowOpen
        cWrFile = SQLVBMain.CommonDialog1.filename
    End If
    '
    If Len(cWrFile) = 0 Then
        intGlobalErr = True
    Else
        nWrFile = FreeFile
        Open cWrFile For Output As nWrFile
    End If
    GoTo AutoGenSQVOpenExit
    '
AutoGenSQVOpenErr:
    If Err <> 32755 Then
        ErrMsg Err, Error$, intLine, strLine, "AutoGenDBOpen"
    End If
    intGlobalErr = True
    '
AutoGenSQVOpenExit:
    '
End Sub

 
< previous page page_904 next page >

If you like this book, buy it!